﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MallInteractiveMap.CMSWebClient.Presenter;
using MallInteractiveMap.DTO;

namespace MallInteractiveMap.CMSWebClient.Handler
{
    /// <summary>
    /// Summary description for PhotoDisplayHandler
    /// </summary>
    public class PhotoDisplayHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            if (Id < 1)
            {
                context.Response.Write("No Image Found.");
                context.Response.End();
            }
            DTOShopPhotos photo = new ShopPresenter().GetPhotosById(Id);
            context.Response.ContentType = photo.FileType;
            context.Response.BinaryWrite(photo.ShopImage);
            context.Response.End();
        }

        public int Id
        {
            get { return HttpContext.Current.Request.QueryString["Id"] != null ? Convert.ToInt32(HttpContext.Current.Request.QueryString["Id"]) : 0; }
        }

       

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}